<template>
  <div>
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>作者平台管理</el-breadcrumb-item>
        <el-breadcrumb-item>PC站运营</el-breadcrumb-item>
        <el-breadcrumb-item>作者咨询管理</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <avue-crud
        :table-loading="loading"
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        :page.sync="page"
        @on-load="getList"
        @refresh-change="refreshChange"
        @search-reset="from = {}"
        @search-change="searchChange"
      >
        <template slot-scope="scoped" slot="menu">
          <el-button icon="" :size="scoped.size" :type="scoped.type" @click="openDialogFn(scoped)">查看详情</el-button>
          <el-button icon="" :size="scoped.size" :type="scoped.type"  @click="openDialogFn(scoped)">回复</el-button>
        </template>
      </avue-crud>
    </basic-container>
    <dialogMy ref="myDialog" @refresh="getList"  :visited="visited" :dialogPage = "dialogPage" :row="row" :messData="messData"></dialogMy>
    <!-- <div title="消息详情"  class="dialogMy" >
      <div>ffdfsddsdsadfsf</div>
    </div> -->
  </div>
</template>

<script>
import { common } from "@/api/cat/httpRequest";
import dialogMy  from "@/views/orangecat/pc/authorCons/dialogMy.vue";

import { catUrl } from "@/config/env";
import {
  pcAuthorAdvisoryReply,selectAdvisoryTypeList
} from "@/api/cat/baseUrls";
import { pcAuthorAdvisory as baseURL} from "@/api/cat/baseUrls";
export default {
  components:{dialogMy},
  data() {
    return {
     visited:false,
     row:[],
     messData:[],
      dialogVisible:true,
      loading: false,
      page: {
        total: 0,
        pageSize: 10,
      },
      dialogPage:{
         total: 0,
        pageSize: 10,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      default: {
        orderByList: "create_time&DESC",
      },
      option: {
        // index: true,
        // indexLabel: "作者ID",
        // excelBtn: false,
        border: true,
        editBtn: false,
        addBtn: false,
        delBtn: false,
        column: [
          {
            label: "作者ID",
            prop: "user_id",
            type: "",
            row: true,
            search: true,
          },
          {
            label: "作者笔名",
            prop: "user_name",
            type: "",
            row: true,
            search: true,
          },
          {
            label: "消息类型",
            prop: "advisory_message_type", //
            type: "select",
            row: true,
            search: true,
             dicUrl: `${catUrl + selectAdvisoryTypeList.selectAdvisoryTypeList}`,
            dicFormatter: (res) => {
              return res.source;
            },
            change:(val)=>{
              this.form.advisory_message_type = val.value
            },
            props:{
              value:'id',
              label:'message_title'
            }
          },
          {
            label: "消息内容",
            prop: "content",
            type: "textarea",
            span: 24,
            row: true,
            rules: [
              {
                required: true,
                message: "推送内容必须填写",
              },
            ],
          },
          {
            label: "发送时间",
            prop: "create_time",
            type: "daterange",
            span: 24,
            row: true,
            search:true
          },
          {
            label: "消息状态",
            prop: "reply_state",
            type: "select",
            row: true,
            search: true,
             type: "select",
            dicData: [
              {
                label: "已回复",
                value: 1,
              },
              {
                label: "待回复",
                value: 0,
              },
            ],
          },
          {
            label: "处理人",
            prop: "last_edit_user_name",
            type: "input",
            row: true,
          },
          {
            label: "操作时间",
            prop: "last_edit_time",
            type: "input",
            row: true,
          },
        ],
      },
    };
  },
  methods: {
    //弹层
  async  openDialogFn(cope){
      this.row = cope.row
      this.$refs['myDialog'].openOrCloseFn()
     let response= await common(
       pcAuthorAdvisoryReply.pageAndParam,
      {advisory_id:cope.row.id},
      this.dialogPage,
      'POST'
      )
      this.messData = response.data
      this.dialogPage = response.page
    
    },
    /**获取列表 */
    async getList() {
      this.loading = true;
      //清空表格列表
      this.data = [];
      //发送请求获取数据
      let response = await common(
        baseURL.pageAndParam,
        { ...this.params },
        this.page,
        "POST"
      );
      this.page = response.page;
      this.data = response.data;
      this.loading = false;
    },
    /**保存 */
    async rowSave(row, done, loading) {
      // delete row["id"];
      // let userInfo = this.$store.state.user.userInfo;
      // row.edit_admin_id = userInfo.id;
      // row.edit_admin_name = userInfo.username;
      // let data = await common(baseURL.save, row, null, "POST");
      // if (data == null) {
      //   loading();
      //   return;
      // }
      // this.getList();
      // done();
    },
    /**修改 */
    async rowUpdate(row, index, done, loading) {
      // let userInfo = this.$store.state.user.userInfo;
      // row.edit_admin_id = userInfo.id;
      // row.edit_admin_name = userInfo.username;
      // let data = await common(baseURL.update, row, null, "POST");
      // if (data == null) {
      //   loading();
      //   return;
      // }
      // this.getList();
      // done();
    },
    /**刷新 */
    refreshChange() {
      this.getList();
    },
    /**删除 */
    rowDel(row) {
      // this.$confirm("此操作将永久删除, 是否继续?", "提示", {
      //   type: "warning",
      // })
      //   .then(async () => {
      //     let response = await common(
      //       baseURL.delete,
      //       { id: row.id },
      //       null,
      //       "GET"
      //     );
      //   })
      //   .then(() => {
      //     this.getList();
      //   });
    },
    /**搜索 */
    searchChange(params, done) {
      params.create_time = `${
        params.create_time ? "!<>!" + params.create_time : ""
      }`;
      this.params = params;
      this.getList();
      if (done) done();
    },
  },
  mounted() {
  },
};
</script>
<style scoped>
.dialogMy{
  width:100%;
  height: 100%;
  position:fixed;
  background: rgba(0,0,0,.5);
  z-index: 3000;
  top:0;
  left: 0;;
}
</style>